//
//  JCRepaymentViewController.m
//  JiFengDaRen
//
//  Created by shouhan on 2018/3/29.
//  Copyright © 2018年 陈永发. All rights reserved.
//

#import "JCRepaymentViewController.h"
#import "JCRepaymentCell.h"
#import "JCCreditManageViewController.h"
#import "JCRepayProgressController.h"

@interface JCRepaymentViewController ()<UITableViewDataSource,UITableViewDelegate,clickActionDelegate>


@property (nonatomic, strong) UITableView * repaymentTableView;

@property (nonatomic, strong) NSMutableDictionary * repayDict;

@end

@implementation JCRepaymentViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"聚能还";
    
    self.view.backgroundColor = [UIColor whiteColor];

    [self repaymentTableView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
   
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 1) {
        JCExplainCell * cell = [JCExplainCell tableViewCellWithTableView:tableView];
        
        return cell;
    }else{
        JCRepaymentCell * cell = [JCRepaymentCell tableViewCellWithTableView:tableView];
        cell.delegate = self;
        [cell layoutIfNeeded];
        return cell;
    }
}
#pragma mark - 懒加载
- (UITableView *)repaymentTableView{
    if (!_repaymentTableView) {
        _repaymentTableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
        _repaymentTableView.delegate = self;
        _repaymentTableView.dataSource = self;
        _repaymentTableView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FB"];
        _repaymentTableView.estimatedRowHeight = 100;
        _repaymentTableView.rowHeight = UITableViewAutomaticDimension;
        _repaymentTableView.separatorStyle =  UITableViewCellSeparatorStyleNone;
        [self.view addSubview:_repaymentTableView];
    }
    
    return _repaymentTableView;
}

#pragma mark - clickActionDelegate
- (void)didClickAction:(UIButton *)btn{
    switch (btn.tag) {
        case 10002:{
            JCRepayProgressController * progressVC = [[JCRepayProgressController alloc] init];
            [self.navigationController pushViewController:progressVC animated:YES];
        }
            break;
        case 10003:{
            JCCreditManageViewController * creditVC = [[JCCreditManageViewController alloc] init];
            [self.navigationController pushViewController:creditVC animated:YES];
        }
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
